package cc.rengu.igas.bomp.common.enums;

import cc.rengu.igas.bomp.common.entity.MchntAuthCtrl;
import cc.rengu.oltp.utility.util.StringUtil;

/**
 * 微信交易枚举
 *
 * @author bank
 * @version 1.0
 * @date 2019/08/15
 */
public enum WechatMchntAuthEnum {

    P01PM00300("P01PM00300", "P01PM003", "00", "02", "微信扫码支付"),
    P04BS00100("P04BS00100", "P04BS001", "00", "02", "微信扫码支付退款(商户服务)"),
    P04PM00300("P04PM00300", "P04PM003", "00", "02", "微信扫码支付退款"),
    P01BS00200("P01BS00200", "P01BS002", "00", "03", "微信条码支付(商户服务)"),
    P01MC02100("P01MC02100", "P01MC021", "00", "03", "微信条码支付"),
    P04BS00200("P04BS00200", "P04BS002", "00", "03", "微信条码支付退款(商户服务)"),
    P04MC02100("P04MC02100", "P04MC021", "00", "03", "微信条码支付退款"),
    P01CP50100("P01CP50100", "P01CP501", "00", "07", "微信公众号支付API"),
    P01CP50200("P01CP50200", "P01CP502", "00", "07", "微信小程序支付API"),
    P01PM00200("P01PM00200", "P01PM002", "00", "07", "收银台微信公众号支付"),
    P01PM00201("P01PM00201", "P01PM002", "01", "07", "收银台微信小程序支付"),
    P01PM00202("P01PM00202", "P01PM002", "02", "07", "收银台微信APP支付"),
    P04BS00300("P04BS00300", "P04BS003", "00", "07", "微信公众号支付退款(商户服务)"),
    P04BS00301("P04BS00301", "P04BS003", "01", "07", "微信小程序支付退款(商户服务)"),
    P04BS00302("P04BS00302", "P04BS003", "02", "07", "微信APP支付退款(商户服务)"),
    P04PM00200("P04PM00200", "P04PM002", "00", "07", "收银台微信公众号支付退款"),
    P04PM00201("P04PM00201", "P04PM002", "01", "07", "收银台微信小程序支付退款"),
    P04PM00202("P04PM00202", "P04PM002", "02", "07", "收银台微信APP支付退款"),

    ;

    public static boolean isWechatAuth(String key) {
        if (StringUtil.isEmptyOrNull(key)) {
            return false;
        }
        for (WechatMchntAuthEnum wechatMchntAuthEnum : WechatMchntAuthEnum.values()) {
            if (wechatMchntAuthEnum.getKey().equals(key)) {
                return true;
            }
        }
        return false;
    }

    public static boolean isWechatAuth(MchntAuthCtrl mchntAuthCtrl) {
        if (null == mchntAuthCtrl) {
            return false;
        }
        return isWechatAuth(mchntAuthCtrl.getTxnNum() + mchntAuthCtrl.getBizType());
    }

    private String key;
    private String txnNum;
    private String bizType;
    private String bizProdCode;
    private String desc;

    WechatMchntAuthEnum(String key, String txnNum, String bizType, String bizProdCode, String desc) {
        this.key = key;
        this.txnNum = txnNum;
        this.bizType = bizType;
        this.bizProdCode = bizProdCode;
        this.desc = desc;
    }

    public String getKey() {
        return key;
    }

    public String getTxnNum() {
        return txnNum;
    }

    public String getBizType() {
        return bizType;
    }

    public String getBizProdCode() {
        return bizProdCode;
    }

    public String getDesc() {
        return desc;
    }
}
